package JZOffer;


// https://leetcode.cn/problems/que-shi-de-shu-zi-lcof/?envType=study-plan&id=lcof&plan=lcof&plan_progress=xxj1ozje
// 0 ~ n-1 中缺失的数字
public class Day004_3 {
    public int missingNumber(int[] nums) {
        if (nums[0] != 0) {
            return 0;
        }
        if (nums.length == 1) {
            return nums.length;
        }
        for (int i = 0; i < nums.length-1; i++) {
            if (nums[i+1] != nums[i]+1) {
                return nums[i]+1;
            }
        }
        return nums.length;
    }
}
